// Thud - a dynamic object-oriented language
// Copyright (C) 2009,2010 David H. Hovemeyer <david.hovemeyer@gmail.com>

// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// 
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
// 
// You should have received a copy of the GNU General Public License
// along with this program.  If not, see <http://www.gnu.org/licenses/>.

/*
 * PreorderASTNodeVisitor.h
 *
 *  Created on: Nov 25, 2009
 *      Author: dhovemey
 */

#ifndef PREORDERASTNODEVISITOR_H_
#define PREORDERASTNODEVISITOR_H_

#include "fe/IASTNodeVisitor.h"

/**
 * Abstract base class for visitors that traverse the
 * parse tree recursively.
 * The default implementation for all non-leaf AST nodes is
 * to visit the child nodes recursively, in order from
 * left to right.
 */
class PreorderASTNodeVisitor : public IASTNodeVisitor {
public:
	/** Constructor. */
	PreorderASTNodeVisitor();
	/** Destructor. */
	virtual ~PreorderASTNodeVisitor();

	// All of the following types of AST nodes have
	// children which (by default) are visited recursively.
	virtual void visitStatementList(ASTNode * n);
	virtual void visitStatement(ASTNode * n);
	virtual void visitWhileStatement(ASTNode * n);
	virtual void visitIfStatement(ASTNode * n);
	virtual void visitBinaryOpExpr(ASTNode * n);
	virtual void visitUnaryOpExpr(ASTNode * n);
	virtual void visitFieldRefExpr(ASTNode * n);
	virtual void visitMethodCallExpr(ASTNode * n);
	virtual void visitModuleMethodCallExpr(ASTNode * n);
	virtual void visitNewExpr(ASTNode * n);
	virtual void visitClass(ASTNode * n);
	virtual void visitModule(ASTNode * n);
	virtual void visitMemberList(ASTNode * n);
	virtual void visitMethod(ASTNode * n);
	virtual void visitMagicMethod(ASTNode * n);
	virtual void visitVarList(ASTNode * n);
	virtual void visitArgList(ASTNode * n);
	virtual void visitUnit(ASTNode * n);
	virtual void visitImportList(ASTNode * n);
	virtual void visitReturnStatement(ASTNode * n);

protected:
	void visitChildren(ASTNode *n);
};

#endif /* PREORDERASTNODEVISITOR_H_ */
